package com.gimc.evil

import org.slf4j.{Logger, LoggerFactory}
import org.springframework.beans.factory.support.{BeanDefinitionBuilder, DefaultListableBeanFactory}
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.{CommandLineRunner, SpringApplication}

/**
 *
 * @author yin.he
 */
object EvilRedisKeyApplication extends App {
  private[this] val applicationContext = SpringApplication.run(classOf[SimpleConfig], args: _ *)
  private[this] val beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(classOf[ApplicationContextHolder])
  applicationContext.getBeanFactory.asInstanceOf[DefaultListableBeanFactory]
    .registerBeanDefinition("applicationContextHolder", beanDefinitionBuilder.getBeanDefinition)
  applicationContext.getBean(classOf[ApplicationContextHolder])
}

@SpringBootApplication
class SimpleConfig extends CommandLineRunner {

  private[this] val LOGGER: Logger = LoggerFactory.getLogger(classOf[SimpleConfig])

  override def run(args: String*): Unit = {
    LOGGER.info("启动输入参数：{}", args)
  }
}
